package com.vietnam.power.persistence;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Type;

import com.vietnam.power.dao.IAuditUpdateTable;

/**
 * The persistent class for the user_info database table.
 * 
 */
@Entity
@Table(name = "user_info")
public class UserInfo implements Serializable, IAuditUpdateTable {
	private static final long serialVersionUID = 1L;
	private Long userInfoId;
	private Date createdDate;
	private String email;
	private String password;
	private byte status;
	private Date updatedDate;
	private String username;
	private File file;
	private boolean accountNonExpired;
	private boolean accountNonLocked;
	private boolean enabled;
	private char gender;
	private byte loginAttemplts;
	private boolean passwordNonExpired;
	private String phone;
	private UserInfo createdBy;
	private UserInfo updatedBy;

	private List<UserAddress> userAddresses;
	private List<UserRole> userRoles;

	public UserInfo() {
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "USER_INFO_ID")
	public Long getUserInfoId() {
		return this.userInfoId;
	}

	public void setUserInfoId(Long userInfoId) {
		this.userInfoId = userInfoId;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CREATED_DATE")
	public Date getCreatedDate() {
		return this.createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public byte getStatus() {
		return this.status;
	}

	public void setStatus(byte status) {
		this.status = status;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "UPDATED_DATE")
	public Date getUpdatedDate() {
		return this.updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}

	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	// bi-directional many-to-one association to File
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "AVATAR_ID")
	public File getFile() {
		return this.file;
	}

	public void setFile(File file) {
		this.file = file;
	}

	@Column(name = "ACCOUNT_NON_EXPIRED")
	@Type(type="true_false")
	public boolean getAccountNonExpired() {
		return this.accountNonExpired;
	}

	public void setAccountNonExpired(boolean accountNonExpired) {
		this.accountNonExpired = accountNonExpired;
	}

	@Column(name = "ACCOUNT_NON_LOCKED")
	@Type(type="true_false")
	public boolean getAccountNonLocked() {
		return this.accountNonLocked;
	}

	public void setAccountNonLocked(boolean accountNonLocked) {
		this.accountNonLocked = accountNonLocked;
	}

	@Type(type="true_false")
	public boolean getEnabled() {
		return this.enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public char getGender() {
		return this.gender;
	}

	public void setGender(char gender) {
		this.gender = gender;
	}

	@Column(name = "LOGIN_ATTEMPLTS")
	public byte getLoginAttemplts() {
		return this.loginAttemplts;
	}

	public void setLoginAttemplts(byte loginAttemplts) {
		this.loginAttemplts = loginAttemplts;
	}

	@Column(name = "PASSWORD_NON_EXPIRED")
	@Type(type="true_false")
	public boolean getPasswordNonExpired() {
		return this.passwordNonExpired;
	}

	public void setPasswordNonExpired(boolean passwordNonExpired) {
		this.passwordNonExpired = passwordNonExpired;
	}

	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	// bi-directional many-to-one association to UserAddress
	@OneToMany(mappedBy = "userInfo")
	public List<UserAddress> getUserAddresses() {
		return this.userAddresses;
	}

	public void setUserAddresses(List<UserAddress> userAddresses) {
		this.userAddresses = userAddresses;
	}

	public UserAddress addUserAddress(UserAddress userAddress) {
		getUserAddresses().add(userAddress);
		userAddress.setUserInfo(this);

		return userAddress;
	}

	public UserAddress removeUserAddress(UserAddress userAddress) {
		getUserAddresses().remove(userAddress);
		userAddress.setUserInfo(null);

		return userAddress;
	}

	// bi-directional many-to-one association to UserRole
	@OneToMany(mappedBy = "userInfo")
	public List<UserRole> getUserRoles() {
		return this.userRoles;
	}

	public void setUserRoles(List<UserRole> userRoles) {
		this.userRoles = userRoles;
	}

	public UserRole addUserRole(UserRole userRole) {
		getUserRoles().add(userRole);
		userRole.setUserInfo(this);

		return userRole;
	}

	public UserRole removeUserRole(UserRole userRole) {
		getUserRoles().remove(userRole);
		userRole.setUserInfo(null);

		return userRole;
	}

	@Override
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="CREATED_BY")
	public UserInfo getCreatedBy() {
		return this.createdBy;
	}

	@Override
	public void setCreatedBy(UserInfo createdBy) {
		this.createdBy = createdBy;
	}

	@Override
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="UPDATED_BY")
	public UserInfo getUpdatedBy() {
		return this.updatedBy;
	}

	@Override
	public void setUpdatedBy(UserInfo updatedBy) {
		this.updatedBy = updatedBy;
	}
}